package com.ibeeking.gmc.global.api.feign.fallback;

import com.ibeeking.found.common.entity.TenantDetailDTO;
import com.ibeeking.found.common.entity.TenantExtendInfo;
import com.ibeeking.gmc.global.api.common.param.*;
import com.ibeeking.gmc.global.api.feign.GlobalTenantFeignClient;
import com.ibeeking.found.common.entity.AreaDTO;
import com.ibeeking.gmc.global.api.common.dto.TenantDTO;
import com.ibeeking.gmc.global.api.common.dto.TenantBankDTO;
import com.ibeeking.gmc.global.api.common.dto.TenantEnterpriseInfoDTO;
import com.ibeeking.gmc.global.api.common.dto.TenantLegalInfoDTO;
import com.ibeeking.nematos.utils.data.Collections3;
import com.ibeeking.nematos.utils.result.ResponseCodeEnum;
import com.ibeeking.nematos.utils.result.ResponseResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 降级工场
 *
 * @Author ibeeking
 * @date 2019/1/18
 */
@Component
public class GlobalTenantFeignFallbackFactory implements FallbackFactory<GlobalTenantFeignClient> {
    @Override
    public GlobalTenantFeignClient create(Throwable throwable) {
        return new GlobalTenantFeignClient() {
            @Override
            public ResponseResult<AreaDTO> queryName(String code) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询地区信息失败。");
            }

            @Override
            public ResponseResult<List<AreaDTO>> queryNames(List<String> codes) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询地区信息失败。", Collections3.emptyList());
            }

            @Override
            public ResponseResult<TenantDTO> queryTenantById(Integer id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询租户信息失败。");
            }

            @Override
            public ResponseResult<TenantDetailDTO> queryDetailByTenantId(Integer type, Integer id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询租户详细信息失败。");
            }

            @Override
            public ResponseResult<Boolean> updateTenantExtendInfo(TenantExtendInfo extendInfo) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，修改租户扩展信息失败。");
            }

            @Override
            public ResponseResult<Boolean> addOrUpdateTenantDetail(TenantDetailParam param) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，修改租户详细信息失败。");
            }

            @Override
            public ResponseResult<String> queryTenantIndustryById(Integer id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询租户行业信息失败。");
            }

            @Override
            public ResponseResult<Boolean> modifyBank(TenantBankParam tenantBankParam) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，修改开户行信息失败。");
            }

            @Override
            public ResponseResult<TenantBankDTO> queryTenantBankByTenantId(Integer id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询开户行信息失败。");
            }

            @Override
            public ResponseResult<TenantEnterpriseInfoDTO> queryEnterpriseInfoByTenantId(Integer id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询企业信息失败。");
            }

            @Override
            public ResponseResult<Boolean> modifyEnterpriseInfo(TenantEnterpriseInfoParam tenantEnterpriseInfoParam) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，修改企业信息失败。");
            }

            @Override
            public ResponseResult<TenantLegalInfoDTO> queryLegalInfoByTenantId(Integer id) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，查询法人信息失败。");
            }

            @Override
            public ResponseResult<Boolean> modifyLegalInfo(TenantLegalInfoParam tenantLegalInfoParam) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，修改法人信息失败。");
            }

            @Override
            public ResponseResult<Boolean> modifyTenant(TenantParam tenantParam) {
                return ResponseResult.fail(ResponseCodeEnum.SYSTEM_ERROR.getCode(), "进入降级工厂，修改租户信息失败。");
            }
        };
    }
}
